local skel = fk.CreateSkill {
  name = "emo__zhanwu",
  dynamic_desc = function (self, player, lang)
    if player:getMark("emo__zhanwu_mode") ~= 0 then
      return "emo__zhanwu_change"
    end
  end,
}

skel:addEffect("viewas", {
  anim_type = "offensive",
  pattern = "slash,duel",
  prompt = function (self, player, selected_cards, selected)
    return "#emo__zhanwu_mode"..player:getMark("emo__zhanwu_mode")
  end,
  card_filter = function (self, player, to_select, selected)
    if #selected > 0 then return false end
    local card = Fk:getCardById(to_select)
    local normal_mode = Self:getMark("emo__zhanwu_mode") == 0
    local c
    if card.color == Card.Red and ((card.type == Card.TypeBasic) == normal_mode) then
      c = Fk:cloneCard("fire__slash")
    elseif card.color == Card.Black and ((card.type ~= Card.TypeBasic) == normal_mode) then
      c = Fk:cloneCard("duel")
    end
    if not c then return false end
    c.skillName = skel.name
    if Fk.currentResponsePattern then
      return Exppattern:Parse(Fk.currentResponsePattern):match(c)
    else
      return player:canUse(c)
    end
  end,
  view_as = function (self, player, cards)
    if #cards ~= 1 then return nil end
    local c
    if Fk:getCardById(cards[1]).color == Card.Red then
      c = Fk:cloneCard("fire__slash")
    elseif Fk:getCardById(cards[1]).color == Card.Black then
      c = Fk:cloneCard("duel")
    end
    if c then
      c.skillName = skel.name
      c:addSubcard(cards[1])
      return c
    end
  end,
  before_use = function(self, player, use)
    if use.card.trueName == "slash" then use.extraUse = true end
  end,
  enabled_at_response = function(self, player, response)
    return not response
  end,
})


Fk:loadTranslationTable{
  ["emo__zhanwu"] = "战舞",
  [":emo__zhanwu"] = "你可以将一张红色基本牌当不计入次数的火【杀】使用。你可以将一张黑色非基本牌当【决斗】使用。",
  [":emo__zhanwu_change"] = "你可以将一张红色非基本牌当不计入次数的火【杀】使用。你可以将一张黑色基本牌当【决斗】使用。",

  ["#emo__zhanwu_mode0"] = "战舞：将红色基本牌当火【杀】，黑色非基本牌当【决斗】使用",
  ["#emo__zhanwu_mode1"] = "战舞：将红色非基本牌当火【杀】，黑色基本牌当【决斗】使用",
}

return skel
